from typing import (
    Optional,
    Union,
    List,
)
import torch
from torchair._ge_concrete_graph.fx2ge_converter import register_fx_node_ge_converter
from torchair.ge._ge_graph import Tensor, TensorSpec

lib = torch.library.Library("air", "FRAGMENT")
lib.define(
    """
    add_custom_tiling_sink(Tensor x, Tensor y) -> Tensor
    """
)


@torch.library.impl(lib, "add_custom_tiling_sink", "Meta")
def kernel_meta(x, y):
    return torch.empty_like(x)


def kernel_impl(x, y):
    raise NotImplementedError("torch.ops.air.add_custom_tiling_sink kernel_impl is not implemented!")


torch.library.impl(lib, "add_custom_tiling_sink", "CPU")(kernel_impl)
torch.library.impl(lib, "add_custom_tiling_sink", "PrivateUse1")(kernel_impl)


@register_fx_node_ge_converter(torch.ops.air.add_custom_tiling_sink.default)
def convert_add_custom_tiling_sink(x: torch.Tensor, y: torch.Tensor, meta_outputs: Union[TensorSpec, List[TensorSpec]] = None):
    return AddCustomTilingSink(x, y)


# This file is auto-generated by
# Summary: total 1, generated 1, skipped 0
from typing import Any, Dict, List, Tuple, Union, Callable, Optional
from torchair.ge._ge_graph import auto_convert_to_tensor, TensorType
from torchair.ge import Tensor, DataType, attr
from torchair._ge_concrete_graph.compat_ir import ge_op, IrDef


# This api is auto-generated from IR AddCustomTilingSink
@auto_convert_to_tensor([False, False], [False, False], inputs_tensor_type=[TensorType.TT_ALL, TensorType.TT_ALL])
def AddCustomTilingSink(x: Tensor, y: Tensor, *, dependencies=[], node_name=None):
    """REG_OP(AddCustomTilingSink)\n
.INPUT(x, TensorType::ALL())\n
.INPUT(y, TensorType::ALL())\n
.OUTPUT(z, TensorType::ALL())\n
"""

    # process inputs
    inputs = {
        "x": x,
        "y": y,
    }

    # process attrs
    attrs = {
    }

    # process outputs
    outputs = [
    "z",
    ]

    return ge_op(
        op_type="AddCustomTilingSink",
        inputs=inputs,
        attrs=attrs,
        outputs=outputs,
        dependencies=dependencies,
        ir=IrDef("AddCustomTilingSink") \
        .input("x", "") \
        .input("y", "") \
        .output("z" , "")
    )
